package structureType.proxy;

import structureType.proxy.agent.AgentImpl;
import structureType.proxy.consumer.AppleConsumerImpl;
import structureType.proxy.consumer.PearConsumerImpl;

public class Main {

    public static void main(String[] args) {

        // 直接访问
        IConsumer appleConsumer = new AppleConsumerImpl();
        appleConsumer.consume();

        IConsumer pearConsumer = new PearConsumerImpl();
        pearConsumer.consume();

        // 代理的方式
        IConsumer agent = new AgentImpl(appleConsumer);
        agent.consume();

        agent = new AgentImpl(pearConsumer);
        agent.consume();
    }
}
